package smartbooks.ui.mainframe;

import java.awt.*;
import java.util.ArrayList;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JLabel;
import javax.swing.JPanel;
import smartbooks.ui.SmartBooksUserSettings;
import smartbooks.ui.customers.CustomersDialog;
import smartbooks.ui.customers.CustomersListDialog;
import smartbooks.ui.options.OptionsDialog;
import smartbooks.ui.orgnanization.OrganizationDialog;
import smartbooks.ui.users.UsersDialog;
import smartbooks.ui.invoices.InvoicesDialog;
import smartbooks.ui.invoices.InvoicesListDialog;
import smartbooks.ui.invoices.InvoicesPanel;
import smartbooks.ui.items.ItemsDialog;
import smartbooks.ui.items.ItemsListDialog;
import smartbooks.ui.items.ItemsListPanel;
import smartbooks.ui.manager.UserOrganizationMappingManager;
import smartbooks.ui.util.CommonConstants;

/**
 *
 * @author Ankit
 */
public class MainFrame extends javax.swing.JFrame implements CommonConstants {
    /**
     * Creates new form MainFrame 
     */
    
    public MainFrame() {
        initComponents();
        
        customInitComponents();
        
        this.setVisible(true);
    }
    
    private void customInitComponents() {
        populateOrganization();
    }
    
    private void populateOrganization() {
        ArrayList<String> organizationNames = UserOrganizationMappingManager.getActiveOrganizationNamesMappedToUser(SmartBooksUserSettings.USER_ID);
        
        organizationComboBox.setModel(new DefaultComboBoxModel(organizationNames.toArray()));
        organizationComboBox.setSelectedItem(SmartBooksUserSettings.DEFAULT_ORG_NAME);
    }
    
    private void addPanelToMainContentPanel(JPanel panel){
        mainContentPanel.removeAll();
        
        mainContentPanel.add(panel);
        Dimension dim = new Dimension((int)panel.getPreferredSize().getWidth()+235, (int)panel.getPreferredSize().getHeight()+112);
        this.setMinimumSize(dim);
        panel.setSize(panel.getPreferredSize());
        
        mainContentPanel.revalidate();
        mainContentPanel.repaint();
    }
    
    private void mouseEnteredInDirectLabel(JLabel label){
        label.setCursor(new Cursor(Cursor.HAND_CURSOR));
    }
    
    private void mouseExitedFromDirectLabel(JLabel label){
        label.setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
    }

    /**
     * This method is used to enable/disable all the components inside the container given
     * @param container
     * @param enabled
     */
    public static void setEnabledAllComponents(Container container, boolean enabled) {
        for (Component component : container.getComponents()) {
            setEnabledAllComponents((Container)component, enabled);
        }
        container.setEnabled(enabled);
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        JInvoicesDialog = new javax.swing.JDialog();
        jPanel2 = new javax.swing.JPanel();
        jToolBar1 = new javax.swing.JToolBar();
        spaces_3 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        spaces_4 = new javax.swing.JLabel();
        jButton2 = new javax.swing.JButton();
        jButton3 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();
        spaces_5 = new javax.swing.JLabel();
        jButton5 = new javax.swing.JButton();
        jButton6 = new javax.swing.JButton();
        directPanel = new javax.swing.JPanel();
        jPanel4 = new javax.swing.JPanel();
        newInvoiceDirectLabel = new javax.swing.JLabel();
        invoicesListDirectLabel = new javax.swing.JLabel();
        jPanel5 = new javax.swing.JPanel();
        newQuoteDirectLabel = new javax.swing.JLabel();
        quotesListDirectLabel = new javax.swing.JLabel();
        newOrderDirectLabel = new javax.swing.JLabel();
        ordersListDirectLabel = new javax.swing.JLabel();
        jPanel6 = new javax.swing.JPanel();
        newItemDirectLabel = new javax.swing.JLabel();
        itemsListDirectLabel = new javax.swing.JLabel();
        jPanel7 = new javax.swing.JPanel();
        newCustomerDirectLabel = new javax.swing.JLabel();
        customersListDirectLabel = new javax.swing.JLabel();
        mainContentPanel = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        organizationComboBox = new javax.swing.JComboBox();
        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();

        JInvoicesDialog.setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        JInvoicesDialog.setTitle("Invoices");
        JInvoicesDialog.setMinimumSize(new java.awt.Dimension(697, 562));
        JInvoicesDialog.setModal(true);
        JInvoicesDialog.setResizable(false);

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Invoices", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 797, Short.MAX_VALUE)
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 604, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout JInvoicesDialogLayout = new javax.swing.GroupLayout(JInvoicesDialog.getContentPane());
        JInvoicesDialog.getContentPane().setLayout(JInvoicesDialogLayout);
        JInvoicesDialogLayout.setHorizontalGroup(
            JInvoicesDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        JInvoicesDialogLayout.setVerticalGroup(
            JInvoicesDialogLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setExtendedState(Frame.MAXIMIZED_BOTH);

        jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);

        spaces_3.setText("   ");
        jToolBar1.add(spaces_3);

        jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/smartbooks/images/invoice_32-32.png"))); // NOI18N
        jButton1.setText("Invoice");
        jButton1.setFocusable(false);
        jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton1);

        spaces_4.setText("   ");
        jToolBar1.add(spaces_4);

        jButton2.setText("Users");
        jButton2.setFocusable(false);
        jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton2);

        jButton3.setText("Customers");
        jButton3.setFocusable(false);
        jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton3);

        jButton4.setText("Items");
        jButton4.setFocusable(false);
        jButton4.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton4.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton4);

        spaces_5.setText("   ");
        jToolBar1.add(spaces_5);

        jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/smartbooks/images/options_32-32.png"))); // NOI18N
        jButton5.setText("Options");
        jButton5.setFocusable(false);
        jButton5.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton5.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton5);

        jButton6.setText("Org");
        jButton6.setFocusable(false);
        jButton6.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jButton6.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });
        jToolBar1.add(jButton6);

        jPanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Invoices", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        newInvoiceDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        newInvoiceDirectLabel.setText("Create New Invoice");
        newInvoiceDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newInvoiceDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                newInvoiceDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                newInvoiceDirectLabelMouseExited(evt);
            }
        });

        invoicesListDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        invoicesListDirectLabel.setText("Open Invoices List");
        invoicesListDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                invoicesListDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                invoicesListDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                invoicesListDirectLabelMouseExited(evt);
            }
        });

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(newInvoiceDirectLabel)
                    .addComponent(invoicesListDirectLabel))
                .addContainerGap(53, Short.MAX_VALUE))
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(newInvoiceDirectLabel)
                .addGap(18, 18, 18)
                .addComponent(invoicesListDirectLabel)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Quotes/Orders", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        newQuoteDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        newQuoteDirectLabel.setText("Create New Quote");
        newQuoteDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newQuoteDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                newQuoteDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                newQuoteDirectLabelMouseExited(evt);
            }
        });

        quotesListDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        quotesListDirectLabel.setText("Open Quotes List");
        quotesListDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                quotesListDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                quotesListDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                quotesListDirectLabelMouseExited(evt);
            }
        });

        newOrderDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        newOrderDirectLabel.setText("Create New Order");
        newOrderDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newOrderDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                newOrderDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                newOrderDirectLabelMouseExited(evt);
            }
        });

        ordersListDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        ordersListDirectLabel.setText("Open Orders List");
        ordersListDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                ordersListDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                ordersListDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                ordersListDirectLabelMouseExited(evt);
            }
        });

        javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
        jPanel5.setLayout(jPanel5Layout);
        jPanel5Layout.setHorizontalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(quotesListDirectLabel)
                    .addComponent(newQuoteDirectLabel)
                    .addComponent(ordersListDirectLabel)
                    .addComponent(newOrderDirectLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel5Layout.setVerticalGroup(
            jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(newQuoteDirectLabel)
                .addGap(18, 18, 18)
                .addComponent(quotesListDirectLabel)
                .addGap(18, 18, 18)
                .addComponent(newOrderDirectLabel)
                .addGap(18, 18, 18)
                .addComponent(ordersListDirectLabel)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel6.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Items", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        newItemDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        newItemDirectLabel.setText("Add New Item");
        newItemDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newItemDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                newItemDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                newItemDirectLabelMouseExited(evt);
            }
        });

        itemsListDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        itemsListDirectLabel.setText("Open Items List");
        itemsListDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                itemsListDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                itemsListDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                itemsListDirectLabelMouseExited(evt);
            }
        });

        javax.swing.GroupLayout jPanel6Layout = new javax.swing.GroupLayout(jPanel6);
        jPanel6.setLayout(jPanel6Layout);
        jPanel6Layout.setHorizontalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(itemsListDirectLabel)
                    .addComponent(newItemDirectLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel6Layout.setVerticalGroup(
            jPanel6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel6Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(newItemDirectLabel)
                .addGap(18, 18, 18)
                .addComponent(itemsListDirectLabel)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jPanel7.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Customers", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Tahoma", 0, 14))); // NOI18N

        newCustomerDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        newCustomerDirectLabel.setText("Add New Customer");
        newCustomerDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                newCustomerDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                newCustomerDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                newCustomerDirectLabelMouseExited(evt);
            }
        });

        customersListDirectLabel.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        customersListDirectLabel.setText("Open Customers List");
        customersListDirectLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                customersListDirectLabelMouseClicked(evt);
            }
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                customersListDirectLabelMouseEntered(evt);
            }
            public void mouseExited(java.awt.event.MouseEvent evt) {
                customersListDirectLabelMouseExited(evt);
            }
        });

        javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
        jPanel7.setLayout(jPanel7Layout);
        jPanel7Layout.setHorizontalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(customersListDirectLabel)
                    .addComponent(newCustomerDirectLabel))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        jPanel7Layout.setVerticalGroup(
            jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel7Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(newCustomerDirectLabel)
                .addGap(18, 18, 18)
                .addComponent(customersListDirectLabel)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout directPanelLayout = new javax.swing.GroupLayout(directPanel);
        directPanel.setLayout(directPanelLayout);
        directPanelLayout.setHorizontalGroup(
            directPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(directPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(directPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(directPanelLayout.createSequentialGroup()
                        .addGroup(directPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jPanel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jPanel5, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                        .addGap(0, 0, Short.MAX_VALUE))
                    .addComponent(jPanel6, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(jPanel7, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap())
        );
        directPanelLayout.setVerticalGroup(
            directPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(directPanelLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jPanel7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(70, Short.MAX_VALUE))
        );

        mainContentPanel.setBackground(new java.awt.Color(255, 255, 255));

        jLabel2.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/smartbooks/images/coins-pile.png"))); // NOI18N

        javax.swing.GroupLayout mainContentPanelLayout = new javax.swing.GroupLayout(mainContentPanel);
        mainContentPanel.setLayout(mainContentPanelLayout);
        mainContentPanelLayout.setHorizontalGroup(
            mainContentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainContentPanelLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel2))
        );
        mainContentPanelLayout.setVerticalGroup(
            mainContentPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, mainContentPanelLayout.createSequentialGroup()
                .addGap(0, 0, Short.MAX_VALUE)
                .addComponent(jLabel2))
        );

        jLabel1.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        jLabel1.setText("Org:");

        organizationComboBox.setFont(new java.awt.Font("Tahoma", 0, 12)); // NOI18N
        organizationComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        organizationComboBox.setFocusable(false);

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(directPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(mainContentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 523, Short.MAX_VALUE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(organizationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, 240, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 59, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(19, 19, 19)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel1)
                            .addComponent(organizationComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(mainContentPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(directPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
        );

        setSize(new java.awt.Dimension(827, 688));
        setLocationRelativeTo(null);
    }// </editor-fold>//GEN-END:initComponents

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        InvoicesDialog invoicesDialog = new InvoicesDialog(this, true);
        invoicesDialog.showDialog();
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        UsersDialog usersDialog = new UsersDialog(this, true, null);
        usersDialog.showDialog();
    }//GEN-LAST:event_jButton2ActionPerformed

    private void newInvoiceDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newInvoiceDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newInvoiceDirectLabelMouseEntered

    private void newInvoiceDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newInvoiceDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newInvoiceDirectLabelMouseExited

    private void invoicesListDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_invoicesListDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_invoicesListDirectLabelMouseEntered

    private void invoicesListDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_invoicesListDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_invoicesListDirectLabelMouseExited

    private void newQuoteDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newQuoteDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newQuoteDirectLabelMouseEntered

    private void newQuoteDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newQuoteDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newQuoteDirectLabelMouseExited

    private void quotesListDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quotesListDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_quotesListDirectLabelMouseEntered

    private void quotesListDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quotesListDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_quotesListDirectLabelMouseExited

    private void newOrderDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newOrderDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newOrderDirectLabelMouseEntered

    private void newOrderDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newOrderDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newOrderDirectLabelMouseExited

    private void ordersListDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ordersListDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_ordersListDirectLabelMouseEntered

    private void ordersListDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ordersListDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_ordersListDirectLabelMouseExited

    private void newItemDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newItemDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newItemDirectLabelMouseEntered

    private void newItemDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newItemDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newItemDirectLabelMouseExited

    private void itemsListDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemsListDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_itemsListDirectLabelMouseEntered

    private void itemsListDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemsListDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_itemsListDirectLabelMouseExited

    private void newCustomerDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newCustomerDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newCustomerDirectLabelMouseEntered

    private void newCustomerDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newCustomerDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_newCustomerDirectLabelMouseExited

    private void customersListDirectLabelMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customersListDirectLabelMouseEntered
        mouseEnteredInDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_customersListDirectLabelMouseEntered

    private void customersListDirectLabelMouseExited(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customersListDirectLabelMouseExited
        mouseExitedFromDirectLabel((JLabel)evt.getComponent());
    }//GEN-LAST:event_customersListDirectLabelMouseExited

    private void newInvoiceDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newInvoiceDirectLabelMouseClicked
        InvoicesPanel invoicesPanel = new InvoicesPanel(null);
        addPanelToMainContentPanel(invoicesPanel);
    }//GEN-LAST:event_newInvoiceDirectLabelMouseClicked

    private void invoicesListDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_invoicesListDirectLabelMouseClicked
        InvoicesListDialog invoicesListDialog = new InvoicesListDialog(this, true);
    }//GEN-LAST:event_invoicesListDirectLabelMouseClicked

    private void newQuoteDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newQuoteDirectLabelMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_newQuoteDirectLabelMouseClicked

    private void quotesListDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_quotesListDirectLabelMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_quotesListDirectLabelMouseClicked

    private void newOrderDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newOrderDirectLabelMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_newOrderDirectLabelMouseClicked

    private void ordersListDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_ordersListDirectLabelMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_ordersListDirectLabelMouseClicked

    private void newItemDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newItemDirectLabelMouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_newItemDirectLabelMouseClicked

    private void itemsListDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_itemsListDirectLabelMouseClicked
        ItemsListDialog itemsListDialog = new ItemsListDialog(this, true);
    }//GEN-LAST:event_itemsListDirectLabelMouseClicked

    private void newCustomerDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newCustomerDirectLabelMouseClicked
        CustomersDialog customersDialog = new CustomersDialog(this, true, null);
        customersDialog.showDialog();
    }//GEN-LAST:event_newCustomerDirectLabelMouseClicked

    private void customersListDirectLabelMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_customersListDirectLabelMouseClicked
        CustomersListDialog customersListDialog = new CustomersListDialog(this, true);
    }//GEN-LAST:event_customersListDirectLabelMouseClicked

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        CustomersDialog customersDialog = new CustomersDialog(this, true, null);
        customersDialog.showDialog();
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        ItemsDialog itemsDialog = new ItemsDialog(this, true, null);
        itemsDialog.showDialog();
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        OrganizationDialog organizationDialog = new OrganizationDialog(this, true, null);
        
        populateOrganization();
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        OptionsDialog optionsDialog = new OptionsDialog(this, true);
        optionsDialog.showDialog();
    }//GEN-LAST:event_jButton5ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(MainFrame.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MainFrame().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JDialog JInvoicesDialog;
    private javax.swing.JLabel customersListDirectLabel;
    private javax.swing.JPanel directPanel;
    private javax.swing.JLabel invoicesListDirectLabel;
    private javax.swing.JLabel itemsListDirectLabel;
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JPanel jPanel5;
    private javax.swing.JPanel jPanel6;
    private javax.swing.JPanel jPanel7;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JPanel mainContentPanel;
    private javax.swing.JLabel newCustomerDirectLabel;
    private javax.swing.JLabel newInvoiceDirectLabel;
    private javax.swing.JLabel newItemDirectLabel;
    private javax.swing.JLabel newOrderDirectLabel;
    private javax.swing.JLabel newQuoteDirectLabel;
    private javax.swing.JLabel ordersListDirectLabel;
    private javax.swing.JComboBox organizationComboBox;
    private javax.swing.JLabel quotesListDirectLabel;
    private javax.swing.JLabel spaces_3;
    private javax.swing.JLabel spaces_4;
    private javax.swing.JLabel spaces_5;
    // End of variables declaration//GEN-END:variables
}
